package basic.algorithm;

/**
 * @创建人 MBY381
 * @创建时间 2022/4/26 14:03
 * @描述 暂无
 */
public class 背包01 {
    static int[] w = {2, 3, 4, 5};
    static int[] v = {3, 4, 5, 6};
    static int capacity = 9;

    public static void main(String[] args) {
        System.out.println(test(0, 0));
    }

    static int test(int index, int weight) {
        if (index >= w.length) return 0;
        if (capacity < weight + w[index]) return 0;
        return Math.max(v[index] + test(index + 1, weight + w[index]), test(index + 1, weight));
    }
}
